﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for AirportBusiness
/// </summary>
public class AirportBusiness
{
	public AirportBusiness()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public bool Insert(AirportEntities item)
    {
        bool flat = false;
        string[] para = { "@airportID", "@cityID", "@airportName", "@airportAddress" };
        string[] values = { item._airportID,item._cityID,item._airportName,item._airportAddress };
        if (DataAccess.getExecProcedure("sp_InsertAirport", para, values) > 0)
        {
            flat = true;
        }
        else
            flat = false;
        return flat;
    }

    public bool Edit(AirportEntities item)
    {
        bool flat = false;
        string[] para = { "@airportID", "@cityID", "@airportName", "@airportAddress" };
        string[] values = { item._airportID, item._cityID, item._airportName, item._airportAddress };
        if (DataAccess.getExecProcedure("sp_UpdateAirport", para, values) > 0)
            flat = true;
        else
            flat = false;
        return flat;
    }

    public bool Delete(AirportEntities item)
    {
        if (DataAccess.getExecProcedure("sp_DeleteAirport", new string[] { "@airportID" }, new string[] { item._airportID }) > 0)
            return true;
        else
            return false;
    }

    public DataTable getAllAirport()
    {
        DataTable dt = new DataTable();
        string query = SQLQuery.SQLQuery_SELECT(new string[] { "tblAirport" }, new string[] { "" }, "", "");
        return dt = DataAccess.DataTable_Query(query); ;
    }

    public DataTable getAirportBy(string[] TableName, string[] fields, string Criterias, string priorities)
    {
        DataTable dt = new DataTable();
        string query = SQLQuery.SQLQuery_SELECT(TableName, fields, Criterias, priorities);
        return dt = DataAccess.DataTable_Query(query);
    }
}